package com.lqian.demo01;

import com.lqian.utils.SleepHelper;

public class Interrupt_and_Interrupted {

    public static void main(String[] args) {
        Thread t = new Thread(()->{
           for (;;){
               // true if the current thread has been interrupted; false otherwise
               if (Thread.interrupted()){
                   System.out.println("Thread is interruped!");
                   System.out.println(Thread.interrupted());
               }
           }
        });

        t.start();
        SleepHelper.sleepSeconds(1);
        //set the interrupt flag
        t.interrupt();
    }
}
